home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / i-cstrin.ads < prev    next >
Text File  |  1996-01-30  |  3KB  |  84 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --                 I N T E R F A C E S . C . S T R I N G S                  --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.7 $                              --
  10. --                                                                          --
  11. -- This specification is adapted from the Ada Reference Manual for use with --
  12. -- GNAT.  In accordance with the copyright of that document, you can freely --
  13. -- copy and modify this specification,  provided that if you redistribute a --
  14. -- modified version,  any changes that you have made are clearly indicated. --
  15. --                                                                          --
  16. ------------------------------------------------------------------------------
  17.  
  18. with System.Storage_Elements;
  19.  
  20. package Interfaces.C.Strings is
  21. pragma Preelaborate (Strings);
  22.  
  23.    type char_array_access is access all char_array;
  24.  
  25.    type chars_ptr is private;
  26.  
  27.    type chars_ptr_array is array (size_t range <>) of chars_ptr;
  28.  
  29.    Null_Ptr : constant chars_ptr;
  30.  
  31.    function To_Chars_Ptr
  32.      (Item      : in char_array_access;
  33.       Nul_Check : in Boolean := False)
  34.       return      chars_ptr;
  35.  
  36.    function New_Char_Array (Chars : in char_array) return chars_ptr;
  37.  
  38.    function New_String (Str : in String) return chars_ptr;
  39.  
  40.    procedure Free (Item : in out chars_ptr);
  41.  
  42.    Dereference_Error : exception;
  43.  
  44.    function Value (Item : in chars_ptr) return char_array;
  45.  
  46.    function Value
  47.      (Item   : in chars_ptr;
  48.       Length : in size_t)
  49.       return   char_array;
  50.  
  51.    function Value (Item : in chars_ptr) return String;
  52.  
  53.    function Value
  54.      (Item   : in chars_ptr;
  55.       Length : in size_t)
  56.       return   String;
  57.  
  58.    function Strlen (Item : in chars_ptr) return size_t;
  59.  
  60.    procedure Update
  61.      (Item   : in chars_ptr;
  62.       Offset : in size_t;
  63.       Chars  : in char_array;
  64.       Check  : Boolean := True);
  65.  
  66.    procedure Update
  67.      (Item   : in chars_ptr;
  68.       Offset : in size_t;
  69.       Str    : in String;
  70.       Check  : in Boolean := True);
  71.  
  72.    Update_Error : exception;
  73.  
  74. private
  75.    type chars_ptr is new System.Storage_Elements.Integer_Address;
  76.  
  77.    Null_Ptr : constant chars_ptr := 0;
  78.    --  A little cleaner might be To_Integer (System.Null_Address) but this is
  79.    --  non-preelaborable, and in fact we jolly well know this value is zero.
  80.    --  Indeed, given the C interface nature, it is probably more correct to
  81.    --  write zero here (even if Null_Address were non-zero).
  82.  
  83. end Interfaces.C.Strings;
  84.